var RetreatOrderForm = function () {
  var template = /* html */ `
    <div class="retreat-order-form" style="padding: 0 20px;padding-bottom: 10px;">
      <el-form :model="orderForm" label-width="130px">
        <el-form-item label="外协退回数量">
          <el-input-number v-model="orderForm.count" :min="1" :max="maxCount" :precision="0" 
            controls-position="right" style="width:200px" @change="handleCountChange"></el-input-number>
          <span>付</span>
        </el-form-item>
        <el-form-item label="外协退回计价数量">
          <el-input-number v-model="orderForm.valuationCount" :min="1" :max="maxValuationCount" :precision="0" 
            controls-position="right" style="width:200px" :disabled="valuationUint==='付'"></el-input-number>
          <span>{{valuationUint}}</span>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="orderForm.remark" type="textarea" :autosize="{maxRows:3}" 
            resize="none" :maxlength="50"></el-input>
        </el-form-item>
      </el-form>
      <div style="text-align:center">
        <el-button type="primary" @click="ensure">确定</el-button>
      </div>
    </div>
  `;

  return {
    props: {
      order: {
        type: Object,
        required: true
      }
    },

    data: function () {
      var order = this.order;
      var valuationUint = order.valuationUint;
      var precision = SysUtil.getMaterialNumberPrecision(valuationUint, 4);
      return {
        maxCount: order.returnCount,
        maxValuationCount: order.returnValuationCount,
        valuationUint:valuationUint,
        precision: precision,
        orderForm: {
          count: order.returnCount,
          valuationCount: order.returnValuationCount,
          remark: ''
        }
      };
    },

    methods: {
      ensure: function () {
        var orderForm = this.orderForm;
        this.$emit('ensure', orderForm, this.order);
      },

      handleCountChange:function(){
        if (this.valuationUint === '付') {
          var orderForm = this.orderForm;
          orderForm.valuationCount = orderForm.count;
        }
      }
    },

    template: template
  };
}();